package com.gupaoedu.vip.singleton;


/**
 * Created by zhaozhonghai on 2017/5/24.
 */
public class Sun {
    private Sun(){
        System.out.println("初始化");
    }
//    private static final Sun sun=new Sun(); //这样写的话 会在sun类加载时就进行初始化
    //静态类 只有用户执行getInstance时 才初始化Sun 于方法执行之前
    private static class LazyHolder{
        private final static Sun sun=new Sun();
    }
    public final static Sun getInstance(){
        System.out.println("执行方法");
        return LazyHolder.sun;
    }

}
